package linkedlist;

/**
 * @author 十八岁讨厌编程
 * @date 2025/6/27 21:09
 * @PROJECT_NAME leetcode
 * @description
 */

public class Solution206 {


    public ListNode reverseList(ListNode head) {
        ListNode reverseResultVirtualHead = new ListNode();
        ListNode pointer = head;
        while (pointer != null) {
            ListNode currentNode = new ListNode(pointer.val, null);
            currentNode.next = reverseResultVirtualHead.next;
            reverseResultVirtualHead.next = currentNode;
            pointer = pointer.next;
        }
        return reverseResultVirtualHead.next;
    }


}
